<?php
$products_id = (int)$_GET['products_id'];

$sqlStr = "SELECT options_id
		   FROM " . TABLE_PRODUCTS_ATTRIBUTES . " a , " . TABLE_PRODUCTS_ATTRIBUTES_IMAGES . " i 
		   WHERE a.products_id = " . $products_id . " 
		   AND i.products_attributes_id = a.products_attributes_id
		   ORDER BY i.image_sort_order";
$result = $db->Execute($sqlStr);
if ($result->recordCount() > 0) {
	while (!$result->EOF) {
		$opt_id_used = $result->fields['options_id'];
		//$opt_values_ids_used[] = $result->fields['options_values_id'];
		$result->MoveNext();
	}
}

?>